import Request from '@/common/utils/request';


// 设置设备工作模式
export async function setDeviceWorkMode(params = {}) {
	Request.isLogin = false; // 需要登录
	const res = await Request.post('/device/user/setDeviceWorkMode', params);
	if (res.data.code === 0) {
		return res.data;
	}
	return Promise.reject(new Error(res.data.message));
}

// 设置设备工作状态
export async function setDeviceWorkStatus(params = {}) {
	Request.isLogin = false; // 需要登录
	const res = await Request.post('/device/user/setDeviceWorkStatus', params);
	if (res.data.code === 0) {
		return res.data;
	} else {
		return res.data
	}
}

// 修改设备工作完成信息
export async function updateIsFinish(params = {}) {
	Request.isLogin = false; // 需要登录
	const res = await Request.post('/device/user/updateIsFinish', params);
	if (res.data.code === 0) {
		return res.data;
	}
}

// 预约设备工作模式
export async function createDeviceScheduleTask(params = {}) {
	Request.isLogin = false; // 需要登录
	const res = await Request.post('/device/user/createDeviceScheduleTask', params);
	if (res.data.code === 0) {
		return res.data;
	}
}




// 预约列表
export async function scheduleTaskList(params = {}) {
	Request.isLogin = false; // 需要登录
	const res = await Request.post('/device/scheduleTask/list', params);
	if (res.data.code === 0) {
		return res.data;
	}
}

// 删除预约
export async function deleteDeviceReservation(params = {}) {
	Request.isLogin = false; // 需要登录
	const res = await Request.post('/device/scheduleTask/cancelDeviceScheduleTask', params);
	if (res.data.code === 0) {
		return res.data;
	}
}